package com.bootdo.appsystem.service.impl;

import com.bootdo.app.utils.redis.AppRedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.bootdo.appsystem.dao.SellerDao;
import com.bootdo.appsystem.domain.SellerDO;
import com.bootdo.appsystem.service.SellerService;



@Service
public class SellerServiceImpl implements SellerService {

	@Autowired
	private SellerDao sellerDao;
	
	@Override
	public SellerDO get(Integer sellerid){
		return sellerDao.get(sellerid);
	}

	@Override
	public SellerDO getSellerByUserId(Integer userId) {
		return sellerDao.getSellerByUserId(userId);
	}

	@Override
	public List<SellerDO> list(Map<String, Object> map){
		return sellerDao.list(map);
	}
	
	@Override
	public int count(Map<String, Object> map){
		return sellerDao.count(map);
	}
	
	@Override
	public int save(SellerDO seller){
		return sellerDao.save(seller);
	}
	
	@Override
	public int update(SellerDO seller){
		return sellerDao.update(seller);
	}
	
	@Override
	public int remove(Integer sellerid){
		return sellerDao.remove(sellerid);
	}
	
	@Override
	public int batchRemove(Integer[] sellerids){
		return sellerDao.batchRemove(sellerids);
	}

	@Override
	public List<SellerDO> getIndexList() {
		List<SellerDO> indexSellerList = null;
		indexSellerList = AppRedisUtil.get("indexSellerList");
		if (indexSellerList == null) {
			HashMap<String, Object> map = new HashMap<>();
			map.put("status" , 1);
			map.put("showindex" , 10);
			indexSellerList = this.list(map);
			AppRedisUtil.put("indexSellerList",indexSellerList);
		}
		return indexSellerList;
	}

}
